#include "BackgroundLayer.h"

BackgroundLayer::BackgroundLayer()
{
}

BackgroundLayer::~BackgroundLayer()
{
}

BackgroundLayer * BackgroundLayer::create()
{
  BackgroundLayer * pLayer = new BackgroundLayer();
  if (pLayer && pLayer->init())
  {
    pLayer->autorelease();
    return pLayer;
  }
  else
  {
    CC_SAFE_DELETE(pLayer);
    return NULL;
  }
}

bool BackgroundLayer::init()
{
  do
  {
    CC_BREAK_IF(!CCLayer::init());
    CCSprite * pBg = CCSprite::create("background.jpg");
    CC_BREAK_IF(!pBg);

    pBg->setAnchorPoint(ccp(0, 0));
    addChild(pBg);

    pBg = CCSprite::create("background.jpg");
    pBg->setAnchorPoint(ccp(0, 0));
    pBg->setPosition(ccp(1708, 0));
    addChild(pBg);

/*    CCFiniteTimeAction * seq = CCSequence::create(CCMoveTo::create(60.0, ccp(-1708, 0)), CCMoveTo::create(0, ccp(0,0)), NULL);
    runAction(CCRepeatForever::create((CCActionInterval*)seq));*/
    return true;
  }
  while(0);
  return false;
}

void BackgroundLayer::setPositionX(float x)
{
  CCLayer::setPositionX(((int)x)%1708);
}
